package com.aplink.generic.pojo.controlspec;

import com.aplink.generic.constant.type.EditTextType;
import com.aplink.generic.util.validation.Validation;

public class EditTextSpec extends ControlSpec {
    public static final int MAX_LENGTH = 255;
    public static final int MIN_LENGTH = 0;
    private static final long serialVersionUID = -4023733878161759862L;
    private boolean isReadOnly;
    private boolean isSearch;
    private EditTextType mDataInputType;
    private int mMaxLength;
    private int mMinLength;
    private String mRegex;
    private String mSearchControl;
    private String mSearchField;
    private Validation mValidation;

    public EditTextSpec() {

    }

    public EditTextSpec(final boolean isReadOnly, final boolean isSearch,
            final Validation validation, final EditTextType dataInputType,
            final String searchControl, final String searchField,
            final int minLength, final int maxLength, final String regex) {
        this.isReadOnly = isReadOnly;
        this.isSearch = isSearch;
        this.mDataInputType = dataInputType;
        this.mSearchControl = searchControl;
        this.mSearchField = searchField;
        this.mMinLength = minLength;
        this.mMaxLength = maxLength;
        this.mValidation = validation;
        setRegex(regex);
    }

    /**
     * The input type of EditText in Android.<br/>
     * This property mapping for "inputtype" attribute.<br/>
     * Example: inputtype="text"
     * 
     * @return DataInputType
     */
    public EditTextType getDataInputType() {
        return this.mDataInputType;
    }

    public int getMaxLength() {
        return this.mMaxLength;
    }

    public int getMinLength() {
        return this.mMinLength;
    }

    public String getRegularExpression() {
        return this.mRegex;
    }

    public String getSearchControl() {
        return this.mSearchControl;
    }

    public String getSearchField() {
        return this.mSearchField;
    }

    public Validation getValidation() {
        return this.mValidation;
    }

    /**
     * The rule to set EditText just read only.<br/>
     * This property mapping for "readonly" element. Example: <readonly/>
     * 
     * @return True or False.
     */
    public boolean isReadOnly() {
        return this.isReadOnly;
    }

    public boolean isSearch() {
        return this.isSearch;
    }

    /**
     * The input type of EditText in Android.<br/>
     * This property mapping for "inputtype" attribute.<br/>
     * Example: inputtype="text"
     * 
     * @param dataInputType
     */
    public void setDataInputType(final EditTextType dataInputType) {
        this.mDataInputType = dataInputType;
    }

    /**
     * The input type of EditText in Android.<br/>
     * This property mapping for "inputtype" attribute.<br/>
     * Example: inputtype="text"
     * 
     * @param dataInputTypeName
     */
    public void setDataInputType(final String dataInputTypeName) {
        this.mDataInputType = EditTextType.get(dataInputTypeName);
    }

    public void setMaxLength(final int maxLength) {
        this.mMaxLength = maxLength;
    }

    public void setMinLength(final int minLength) {
        this.mMinLength = minLength;
    }

    /**
     * The rule to set EditText just read only.<br/>
     * This property mapping for "readonly" element. Example: <readonly/>
     * 
     * @param isReadOnly
     */
    public void setReadOnly(final boolean isReadOnly) {
        this.isReadOnly = isReadOnly;
    }

    public void setRegex(final String regex) {
        this.mRegex = regex;
    }

    public void setSearch(final boolean isSearch) {
        this.isSearch = isSearch;
    }

    public void setSearchControl(final String searchControl) {
        this.mSearchControl = searchControl;
    }

    public void setSearchField(final String searchField) {
        this.mSearchField = searchField;
    }

    public void setValidation(final Validation validation) {
        this.mValidation = validation;
    }

}
